//
//  ClassifyCollectionViewCell.m
//  美食百科
//
//  Created by dllo on 16/1/23.
//  Copyright © 2016年 doll. All rights reserved.
//

#import "ClassifyCollectionViewCell.h"
#import "ClassModel.h"
#import "UIImageView+WebCache.h"
@interface ClassifyCollectionViewCell()
@property(nonatomic,retain)UIImageView *imageView;
@property(nonatomic,retain)UILabel *label;
@end
@implementation ClassifyCollectionViewCell
- (void)dealloc
{
    [_imageView release];
    [_classModel release];
    [_label release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.imageView = [[UIImageView alloc]init];
       // self.imageView.backgroundColor = [UIColor orangeColor];
        [self.contentView addSubview:self.imageView];
        [_imageView release];
        
        self.label = [[UILabel alloc]init];
        //self.label.backgroundColor = [UIColor blueColor];
        self.label.textAlignment = NSTextAlignmentCenter;
        self.label.textColor = self.color;

        self.label.lineBreakMode = NSLineBreakByTruncatingMiddle;
        [self.contentView addSubview:self.label];
        
        [_label release];
        
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    self.imageView.frame = CGRectMake(30, 15, self.frame.size.width-60, self.frame.size.height*2/3-15);
    
    self.label.frame = CGRectMake(20, self.frame.size.height*2/3, self.frame.size.width-40, self.frame.size.height*1/3);
}

-(void)setClassModel:(ClassModel *)classModel
{
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:classModel.image_url]placeholderImage:[UIImage imageNamed:@"u=1023456699,842778947&fm=21&gp=0"]];
    self.label.text = classModel.name;
}
@end
